import { Map } from "immutable";
import { CHANGE_ADMIN_INFO, CHANGE_LOGIN_STATE } from "../type";
const reducer = (
    state = Map({
        adminInfo:JSON.parse(window.localStorage.getItem("adminInfo")) || '',
        loginState:JSON.parse(window.localStorage.getItem("loginState")) || false
    }),
    { type, payload }
) => {
    switch (type) {
        case CHANGE_ADMIN_INFO:
            window.localStorage.setItem("adminInfo", JSON.stringify(payload));
            return state.set("adminInfo", payload);
        case CHANGE_LOGIN_STATE:
            window.localStorage.setItem("loginState", JSON.stringify(payload));
            return state.set("loginState", payload);
        default:
            return state;
    }
}
export default reducer